package kr.hkit.androidcomplete01;

import kr.hkit.androidcomplete01.ch04.Ch04Main;
import kr.hkit.androidcomplete01.ch05.Ch05Main;
import kr.hkit.androidcomplete01.ch06.Ch06Main;
import kr.hkit.androidcomplete01.ch07.Ch07Main;
import kr.hkit.androidcomplete01.ch08.Ch08Main;
import kr.hkit.androidcomplete01.ch09.Ch09Main;
import kr.hkit.androidcomplete01.ch11.Ch11Main;
import kr.hkit.androidcomplete01.ch12.Ch12Main;
import kr.hkit.androidcomplete01.ch13.Ch13Main;
import kr.hkit.androidcomplete01.ch14.Ch14Main;
import kr.hkit.androidcomplete01.ch15.Ch15Main;
import kr.hkit.androidcomplete01.ch16.Ch16Main;
import kr.hkit.androidcomplete01.ch17.Ch17Main;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends ListActivity {
	private String[] lists;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
//		setContentView(R.layout.activity_main);
		
		lists = getResources().getStringArray(R.array.main_list);
		
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, lists);
		setListAdapter(adapter);
	}
	
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		/*String text = "View v =" + v.toString() + " : position =" + position + ", id = " + id;
		Toast.makeText(this, text, Toast.LENGTH_LONG).show();*/
		Intent intent = null;
		switch(position){
			case 0:
				intent = new Intent(this, Ch04Main.class);
				break;
			case 1:
				intent = new Intent(this, Ch05Main.class);
				break;
			case 2:
				intent = new Intent(this, Ch06Main.class);
				break;
			case 3:
				intent = new Intent(this, Ch07Main.class);
				break;
			case 4:
				intent = new Intent(this, Ch08Main.class);
				break;
			case 5:
				intent = new Intent(this, Ch09Main.class);
				break;
			case 6:
				intent = new Intent(this, Ch11Main.class);
				break;
			case 7:
				intent = new Intent(this, Ch12Main.class);
				break;
			case 8:
				intent = new Intent(this, Ch13Main.class);
				break;
			case 9:
				intent = new Intent(this, Ch14Main.class);
				break;
			case 10:
				intent = new Intent(this, Ch15Main.class);
				break;
			case 11:
				intent = new Intent(this, Ch16Main.class);
				break;
			case 12:
				intent = new Intent(this, Ch17Main.class);
				break;
		}
		startActivity(intent);
	}
}
